import 'dart:convert';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter_aygsh/base/Constant.dart';
import './CollectBrandList.dart';
import './CollectGoodsList.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class CollectPage extends StatefulWidget {
  CollectPage({Key key}) : super(key: key);

  @override
  _CollectPageState createState() => _CollectPageState();
}

class _CollectPageState extends State<CollectPage> {
  TabController _tabController;
  List<String> tabs = ["商品", "品牌"];
  @override
  Widget build(BuildContext context) {
    return new DefaultTabController(
        length: tabs.length,
        child: Scaffold(
            appBar: new AppBar(
              flexibleSpace: Container(
                decoration: BoxDecoration(
                    color:Color.fromARGB(255, 255, 140, 16),
                ),
              ),
              title: Text('我的收藏',
                  style: TextStyle(
                      fontSize: ScreenUtil.getInstance().setSp(BIG_FONT_SIZE),
                      color: Colors.white)),
              backgroundColor: Colors.white,
              brightness: Brightness.light,
              centerTitle: true,
              iconTheme: new IconThemeData(color: Colors.white),
              elevation: 0.5,
              bottom: TabBar(
                indicatorColor:white,
                labelColor: white,
                unselectedLabelColor: Colors.white,
                isScrollable: true,
                tabs: tabs.map((item) {
                  return _tabsBuilder(context, item);
                }).toList(),
                controller: _tabController,
                onTap: (index) {},
              ),
            ),
            body: TabBarView(
              children: tabs.map<Widget>((item) {
                if (item == '商品') {
                  return CollectGoodsListPage();
                } else {
                  return CollectBrandListPage();
                }
              }).toList(),
            )));
  }

  Widget _tabsBuilder(BuildContext context, item) {
    return Tab(
      text: item,
    );
  }
}
